
<link rel="stylesheet" href="/static/admin/layui/css/layui.css">
<style>
	.layui-form-checkbox{margin-top: 5px;margin-bottom: 5px;}
</style>
<section id="content" style="padding: 10px;">
	<form class="layui-form">

<div class="layui-collapse">
	{% for opt in opts %}

	{% if opt.category%2===1 %}
	<div class="layui-colla-item">
		<h2 class="layui-colla-title">{{opt.name}}</h2>
		<div class="layui-colla-content layui-show">
			<input type="checkbox" name="all" title="全选">
			{% for o in opts %}
			
			{% if o.pid===opt.id %}
			<input type="checkbox" name="item" value="{{o.tags}}" title="{{o.name}}"
			{% for q in qinfo %}
				{% if q===o.tags %}
					checked
				{% endif %} 
			{% endfor %}
			>
			{% endif %}

			{% endfor %}
		</div>
	</div>
	{% endif %}

	{% endfor %}
</div>

	</form>
</section>

<script src="/static/admin/js/jquery.min.js"></script>
<script src="/static/admin/layer/layer.js"></script>
<script src="/static/admin/layui/layui.js"></script>
<script src="/static/admin/js/h.js"></script>
<script src="/static/admin/eleme/vue.js"></script>
<script>
var qxs = [
	{% for q in qinfo %}
	"{{ q }}",
	{% endfor %}
];

var total = [
	{% for o in opts %}
	"{{ o.tags }}",
	{% endfor %}
];
let submodel = {};
layui.use(['form','element'], function(){
	var form = layui.form;
	var element = layui.element;
	form.on('checkbox', function(data){

		if (data.elem.name === 'all') {
			if (data.elem.checked) {
				$(data.elem).parent().children('input').prop('checked',true);
				form.render();
			} else {
				$(data.elem).parent().children('input').prop('checked',false);
				form.render();
			}
		}

	})
});

function call_submit(index){

	let qxlist = [];

	for(var i = 0, itemlen = $('input[name="item"]').length; i < itemlen; i++) {
		if ($('input[name="item"]').eq(i).prop('checked')) qxlist.push($('input[name="item"]').eq(i).val());
	}

	H.ajax('/admin/fenpei/setquan',{data: JSON.stringify(qxlist), id: {{id}}}, 'post', function(res){
		parent.layer.msg(res.data, {icon:1, time:2000});
		setTimeout(function(){
			parent.layer.close(index);
		}, 2000)
		
	})

}

</script>
